import {http} from "../utils/http";
import {RootObjectData} from "@/views/main/index.vue";

type ResponseData<T> = {
    code: number;
    msg: string;
    data: T;
};


export type ApplyLoanDTO = {
    /** 手机号 */
    phone: any;
    /** 验证码 */
    captchaCode: any;
};

/**
 * 登录
 */
export const applyLoan = (data: ApplyLoanDTO) => {
    return http.request<ResponseData<void>>("post", "/common/apply/login", {data});
}

/**
 * 发送验证码
 * @param data
 */
export const sendSms = (data: any) => {
    return http.request<ResponseData<void>>("post", "/common/send/sms", {data});
}


/**
 * 申请贷款
 */
export const applicationLoan = (data: any) => {
    return http.request<ResponseData<void>>("post", "/app/loan/application", {data});
}

/**
 * 获取产品信息
 */
export const getProductInfo = (data:any) => {
    return http.request<ResponseData<void>>("post", "/app/product/info",{data});
}


/**
 * 获取用户信息
 */
export const getUserInfo = () => {
    return http.request<ResponseData<RootObjectData>>("get", "/app/user/info");
}



/**
 * 上传文件
 */
export const uploads = (data: any) => {
    return http.request<ResponseData<void>>("post", "/app/uploads/files", {data}, {
        headers: {
            "Content-Type": "multipart/form-data"
        }
    });
}
